package com.gitee.huanminabc.utils_tools.security.core;

import com.gitee.huanminabc.jcommon.encryption.HashUtil;
import org.springframework.security.crypto.password.PasswordEncoder;

public class MD5PasswordEncoder implements PasswordEncoder {
    /**
     * @param charSequence 前端传过来的密码,需要加密为MD5后面需要和数据库中的密码进行比较
     * @return
     */
    @Override
    public String encode(CharSequence charSequence) {
        return HashUtil.md5(charSequence.toString());
    }

    /**
     * @param charSequence 前端传过来的密码
     * @param s 数据库中的密码
     * @return
     */
    @Override
    public boolean matches(CharSequence charSequence, String s) {
        return s.equals(HashUtil.md5(charSequence.toString()));
    }
}
